package com.example.hao.flowercityfm.mvp.modle;

import android.util.Log;

import com.example.hao.flowercityfm.pojo.HomeFragmentData;
import com.example.hao.flowercityfm.utils.RetrofitClient;

import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Consumer;
import io.reactivex.schedulers.Schedulers;

public class HomeFModel implements IHomeFModel {
    private static final String TAG = "ABC";
    @Override
    public void loadData( final onCallBack callBack) {
        Disposable subscribe = RetrofitClient.getApiRequestService().loadData()
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Consumer<HomeFragmentData>() {
                    @Override
                    public void accept(HomeFragmentData homeData) throws Exception {
                        Log.d(TAG, "accept: "+homeData);
                        callBack.onSuccess(homeData);
                    }
                }, new Consumer<Throwable>() {
                    @Override
                    public void accept(Throwable throwable) throws Exception {
                        callBack.onFailure(throwable);
                    }
                });


//        RetrofitClient.getClient()
    }


}
